<template>
  <div class="app-con">
    <MyHeader title="购物车首页" backgroundColor="blue" color="red"></MyHeader>
    <MyGoods v-for="item in list" :key="item.id" :goods="item"></MyGoods>
    <MyFooter @changeAll="all" :arr="list"></MyFooter>
  </div>
</template>

<script>
import MyHeader from './components/MyHeader.vue'
import MyGoods from './components/MyGoods.vue'
import MyFooter from './components/MyFooter.vue'
export default {
 components:{
   MyHeader,
   MyGoods,
   MyFooter
 },

  data() {
    return {
        list: []  
    };
  },
  async  created(){
  let res =await this.$axios.get('/api/cart')
  this.list =res.data.list
},
  methods: {
    all(bool){
this.list.forEach(item=>item.goods_state = bool)
    }
  },
};
</script>

<style lang="less" scoped>
.app-con{
  padding-top: 45px;
}
</style>